<?php


namespace app\game;


use app\game\node\AbsNode;

class RandRowCol
{
    /**
     * 依据
     * @var Form
     */
    protected $form;

    /**
     * @param Form $form
     */
    public function setForm($form)
    {
        $this->form = $form;
    }

    public function createRowCol()
    {
        $array = $this->form->getAllFormNode();

        if (!$array){
            throw new \Exception('game over~');
        }

        $index = array_rand($array);

        /**
         * @var AbsNode $node
         */
        $node = $array[$index];

        return [
            $node->getRow(),
            $node->getCol()
        ];
    }
}